package com.jingsheng.jingshengcity.mvp.ui.activity.wallet;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.UiUtils;
import com.jingsheng.jingshengcity.R;
import com.jingsheng.jingshengcity.di.component.DaggerShareProfitComponent;
import com.jingsheng.jingshengcity.di.module.ShareProfitModule;
import com.jingsheng.jingshengcity.mvp.contract.ShareProfitContract;
import com.jingsheng.jingshengcity.mvp.presenter.ShareProfitPresenter;
import com.jingsheng.jingshengcity.mvp.ui.adapter.ShareProfitActivityAdapter;
import com.jingsheng.jingshengcity.widgets.decoration.GridItemDecoration;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

import static com.jess.arms.utils.Preconditions.checkNotNull;

/**
 * Created by Administrator on 2017/5/13.
 */

public class ShareProfitActivity extends BaseActivity<ShareProfitPresenter> implements ShareProfitContract.View {

    @NonNull
    @BindView(R.id.rv_list)
    RecyclerView mRecyclerView;

    private List<String> mList = new ArrayList<>();

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerShareProfitComponent
                .builder()
                .appComponent(appComponent)
                .shareProfitModule(new ShareProfitModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView() {
        setTitle("分享收益");
        return R.layout.activity_share_profit;
    }

    @Override
    public void initData() {

        mList.add("1");
        mList.add("1");
        mList.add("1");

        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        ShareProfitActivityAdapter mBankCardActivityAdapter = new ShareProfitActivityAdapter(R.layout.adapter_share_profit_item, mList);
        mBankCardActivityAdapter.openLoadAnimation();
        mRecyclerView.addItemDecoration(new GridItemDecoration(this, R.drawable.list_gray_devider));
        mRecyclerView.setAdapter(mBankCardActivityAdapter);

        mBankCardActivityAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                toDetail();
            }
        });
    }

    private void toDetail() {
        Intent intent = new Intent(this, ShareProfitDetailActivity.class);
        startActivity(intent);
    }


    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        UiUtils.SnackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        UiUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }


}